<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <title> QQConnect JSDK - redirectURI </title>

        <script src="@routes.Assets.versioned("javascripts/jquery.min.js")"></script>
        <link rel="shortcut icon" href="@routes.Assets.versioned("images/favicon.png")" />
        <script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" data-appid="101253933" data-redirecturi="http://xjpz.me/blog/test/qcback" charset="utf-8"></script>

        <style type="text/css">
        html, body{font-size:14px; line-height:180%;}
        </style>
        <script>
            var _hmt = _hmt || [];
            (function() {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?a43a6a0c825c678693fcedd5df8e869d";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        </script>

    </head>
    <body onload="getInfo()">

        <div>
            <h3>正在授权，请稍后...</h3>
        </div>

    </body>
</html>


<script type="text/javascript">

            function getInfo() {
                if(QC.Login.check()){
                    QC.api("get_user_info")
                        .success(function(s){//成功回调
                            QC.Login.getMe(function(openId, accessToken){
                                $.post('@routes.UserController.loginByQConn',{name:s.data.nickname,openid:openId,otype:1,token:accessToken},function(data,status){
                                    if(status=="success"){
                                        try {
                                            if (window.opener.location.href.indexOf("xjpz.me/blog/login") >= 0)
                                                window.opener.location.href = "/";
                                            else
                                                window.opener.location.reload(true);//强制刷新
                                        } catch (e) {
                                            alert("自动刷新或跳转失败~");
                                            location.href = "/";
                                        }
                                        window.close();
                                    }else{
                                        alert("获取用户信息成功！登录失败！");
                                        location.href = "/blog/login";
                                    }
                                })
                            })
                        })
                        .error(function(f){//失败回调
                            alert("获取用户信息失败！登录失败！");
                        })
                        .complete(function(c){//完成请求回调
                        //	alert("获取用户信息完成！");
                        });
                }else{
                    alert("请登录！");
                }
            }
</script>
